<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            margin: 0;
            padding: 0;
            background-image: url('../00-images/grid.png');
        }
        #can{
           background-color: rgba(255, 0, 0, .5);
        }
    </style>
</head>
<body>
    <canvas id="can" width="300px" height="300px"></canvas>
    <script>
        window.onload = ()=>{
            //先获取cnavas元素
            const cav = document.getElementById('can');
            console.log(cav);
            //获取canvas元素的画布
            const ctx = cav.getContext('2d');
            if(!ctx) return
            console.log(ctx);
            //使用画布内的api进行操作
        }
    </script>
</body>
</html>